<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width, initial-scale=1.0,maximum-scale=1.0, user-scalable=0">

		<title>地址管理</title>

		<link href="/Public/assets/css/admin.css" rel="stylesheet" type="text/css">
		<link href="/Public/assets/css/amazeui.css" rel="stylesheet" type="text/css">

		<link href="/Public/css/personal.css" rel="stylesheet" type="text/css">
		<link href="/Public/css/addstyle.css" rel="stylesheet" type="text/css">
		<script src="/Public/assets/js/jquery.min.js" type="text/javascript"></script>
		<script src="/Public/assets/js/amazeui.js"></script>
		<link rel="stylesheet" href="/Public/css/demo.css">
		<link rel="stylesheet" href="/Public/css/layout.css">
		<script src="/Public/home/user.js"></script>		

	</head>

	<body>
		<!--头 -->
		<header>
			<article>
				<div class="mt-logo">
					<!--顶部导航条 -->
					<include file="./Application/Home/View/Share/header.html" />
				</div>
			</article>
		</header>

		<div class="nav-table">
			<div class="long-title"><span class="all-goods">全部分类</span></div>
			<div class="nav-cont">
				<ul>
					<li class="index"><a href="#">首页</a></li>
					<li class="qc"><a href="#">闪购</a></li>
					<li class="qc"><a href="#">限时抢</a></li>
					<li class="qc"><a href="#">团购</a></li>
					<li class="qc last"><a href="#">大包装</a></li>
				</ul>
				<div class="nav-extra">
					<i class="am-icon-user-secret am-icon-md nav-user"></i><b></b>我的福利
					<i class="am-icon-angle-right" style="padding-left: 10px;"></i>
				</div>
			</div>
		</div>
		<b class="line"></b>

		<div class="center">
			<div class="col-main">
				<div class="main-wrap">

					<div class="user-address">
						<!--标题 -->
						<div class="am-cf am-padding">
							<div class="am-fl am-cf"><strong class="am-text-danger am-text-lg">地址管理</strong> / <small>Address&nbsp;list</small></div>
						</div>
						<hr/>
						<ul class="am-avg-sm-1 am-avg-md-3 am-thumbnails">
							<volist name="list" id="vo">
							<li class="user-addresslist">
								<span class="new-option-r" onclick="javascript:defaddress(this);"><i class="am-icon-check-circle"></i>设为默认</span>
								<p class="new-tit new-p-re">
									<input type="hidden" class="hres" value="{$vo.id}">
									<input type="hidden" class="hres1" value="{$vo.click}">
									<span class="new-txt">{$vo.name}</span>
									<span class="new-txt-rd2">{$vo.telephone}</span>
								</p>
								<div class="new-mu_l2a new-p-re">
									<p class="new-mu_l2cw">
										<span class="title">地址：</span>
										<span class="province">{$vo.province}</span>
										<span class="city">{$vo.city}</span>
										<span class="dist">{$vo.area}</span>
										<span class="street">{$vo.intro}</span></p>
								</div>
								<div class="new-addr-btn">
									<a href="/Home/user/edit?id={$vo.id}"><i class="am-icon-edit"></i>编辑</a>
									<span class="new-addr-bar">|</span>
									<a href="/home/user/edit?id={$vo.id}&act=t_del" ><i class="am-icon-trash"></i>删除</a>
								</div>
							</li>
							</volist>
							
						</ul>
						<div class="clear"></div>
						<a class="new-abtn-type" data-am-modal="{target: '#doc-modal-1', closeViaDimmer: 0}">添加新地址</a>
						<!--例子-->
						<div class="am-modal am-modal-no-btn" id="doc-modal-1">

							<div class="add-dress" id="address-hide">

								<!--标题 -->
								<div class="am-cf am-padding">
									<div class="am-fl am-cf"><strong class="am-text-danger am-text-lg">新增地址</strong> / <small>Add&nbsp;address</small></div>
								</div>
								<hr/>

								<div class="am-u-md-12 am-u-lg-8" style="margin-top: 20px;">
									<form class="am-form am-form-horizontal"  method="post">

										<div class="am-form-group">
											<label for="user-name" class="am-form-label">收货人</label>
											<div class="am-form-content">
												<input type="text" id="user-name" placeholder="收货人">
											</div>
										</div>

										<div class="am-form-group">
											<label for="user-phone" class="am-form-label">手机号码</label>
											<div class="am-form-content">
												<input id="user-phone" placeholder="手机号必填" type="text">
											</div>
										</div>
										<div class="am-form-group">
											<label for="user-address" class="am-form-label">所在地</label>
											<div class="am-form-content address">
												<fieldset id="city_china_val">
													<select id="user-province" class="province cxselect" data-value="浙江省" data-first-title="选择省" ></select>
													<select id="user-city" class="city cxselect" data-value="杭州市" data-first-title="选择市" ></select>
													<select id="user-area" class="area cxselect" data-value="西湖区" data-first-title="选择地区" ></select>
												</fieldset>
											</div>
										</div>

										<div class="am-form-group">
											<label for="user-intro" class="am-form-label">详细地址</label>
											<div class="am-form-content">
												<textarea class="" rows="3" id="user-intro" placeholder="输入详细地址" ></textarea>
												<small>100字以内写出你的详细地址...</small>
											</div>
										</div>

										<div class="am-form-group">
											<div class="am-u-sm-9 am-u-sm-push-3">
												<a class="am-btn am-btn-danger" onclick="USER.useraddress();">保存</a>
												<a href="{$list.id}" class="am-close am-btn am-btn-danger" data-am-modal-close>取消</a>
											</div>
										</div>
									</form>
								</div>

							</div>
							<div class="add-dress" id="address-show">
								
							</div>

						</div>

					</div>
					
					<script type="text/javascript">
						//默认地址设置
						$(document).ready(function() {		
							$(".new-option-r").click(function() {
								$(this).parent('.user-addresslist').addClass("defaultAddr").siblings().removeClass("defaultAddr");
								$(this).html("默认地址");
							});
							
							var $ww = $(window).width();
							if($ww>640) {
								$("#doc-modal-1").removeClass("am-modal am-modal-no-btn")
							}
							
						})
					</script>

					<div class="clear"></div>

				</div>
				<!--底部-->
				<include file="./Application/Home/View/Share/footer.html" />
			</div>

			<aside class="menu">
				<include file="./Application/Home/View/Share/menu.html" />

			</aside>
		</div>

	</body>

</html>

<script src="/Public/js/jquery-1.7.2.min.js"></script>
<script src="/Public/js/jquery.cxselect.min.js"></script>

<script>
//城市js
$.cxSelect.defaults.url = '/Public/js/cityData.min.json';

$('#city_china_val').cxSelect({
	selects: ['province', 'city', 'area'],
	nodata: 'none'
});

//获取URL的id
function getprogram(name) { 
	var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i"); 
	var r = window.location.search.substr(1).match(reg); 
	if (r != null) return unescape(r[2]); return null; 
} 
var id = getprogram('id');

function defaddress(obj){
	var click = $(obj).parents('.user-addresslist').find('.hres').val();
	$.get('/Api/Address/defaddress' , {click:click} , function(ret){
		if( ret.status == true){
			alert(ret.data);
		}
		else{
			alert(ret.data);
		}
	});
}

USER.run();
</script>
